package au.com.handsunited.model.validators.address;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

import au.com.handsunited.model.Address;


/**
 * @author arunda
 *
 */
public class OrganisationAddressValidator extends AddressValidator {

	private static Logger logger = LoggerFactory.getLogger(OrganisationAddressValidator.class);

	/**
	 *
	 */
	public OrganisationAddressValidator() {
		super();
	}


	/**
	 * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	@Override
	public void validate(Object target, Errors errors) {

		super.validate(target, errors);

		Address address = (Address) target;

		ValidationUtils.rejectIfEmpty(errors, "street", "organisation.address.street.required", "Street is required");
		ValidationUtils.rejectIfEmpty(errors, "suburb", "organisation.address.suburb.required", "Suburb is required");
		ValidationUtils.rejectIfEmpty(errors, "city", "organisation.address.city.required", "City is required");
		ValidationUtils.rejectIfEmpty(errors, "state", "organisation.address.state.required", "State is required");
		ValidationUtils.rejectIfEmpty(errors, "postcode", "organisation.address.postcode.required", "Postcode is required");
		ValidationUtils.rejectIfEmpty(errors, "country", "organisation.address.country.required", "Country is required");
	}


}
